﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>将URL转化为16进制</title>
    <script type="text/javascript" language="JavaScript">
        function convertUrl(str){
            let newStr ='';
            for(let i = 0;i< str.length;i++){
                let ch = str.charAt(i);         // 显示当前位置的字母
                let code = str.charCodeAt(i);   // 显示当前位置的字母的键值
                newStr += code.toString(16);    // 16进制显示
            }
            alert(newStr);
        }
        
    </script>
</head>
<body>
<input id="Button1" type="button" value="转化" onclick="ConvertUrl('http://WWW.jd.COM')" />
</body>
</html>